package st.mark.quadtris;

import java.util.Random;

import org.newdawn.slick.Music;
import org.newdawn.slick.SlickException;

public class MusicManager {
	
	public static boolean ready = false;
	
	private static int current = 0;
	private static Music[] music = new Music[4];
	
	private static Random rnd = new Random();
	
	public static void init() throws SlickException{
		music[0] = new Music("st/mark/resources/audio/music_1.ogg");
		music[1] = new Music("st/mark/resources/audio/music_2.ogg");
		music[2] = new Music("st/mark/resources/audio/music_3.ogg");
		music[3] = new Music("st/mark/resources/audio/music_4.ogg");
		
		current = rnd.nextInt(4);
		
		music[current].play();
	}
	
	public static void update(){
		
		if(!music[current].playing()){
			current++;
			
			if(current == music.length)
				current = 0;
			
			music[current].play();
		}
		
	}
}
